#ifndef _PAGE_GUI_H
#define _PAGE_GUI_H
/*
 *  cpu_gui/w_pagew.h
 *  
 *              CPU Monitor 
 *
 *    Spring Semester.  044800.    Technion.
 *   Copyright (C) 2006  Evgeny Shulman  and Elizabeth Shtrom 
 */

#include <QWidget>
#include "../cpu_common.h"
#include "../cpu_functions.h"

extern int fd[8];

/******************** Default Tab **********************/
 class  MonitorPageTab : public QWidget
 {
public:
     Q_OBJECT
public:     
	MonitorPageTab(QWidget *parent = 0) :  QWidget(parent) , CurrCpu(0),UpdatedCpu(-1), isUpdateOnShow(0) 
		 { *mainPid = '\0';
		   *dataPid= '\0';   }
	const char* getMainPid(void) { return mainPid; }
	const char* getDataPid(void) { return dataPid; }
	void setPid(int main, int data) { 
		   sprintf ( mainPid,"%d",main) ;
		   sprintf ( dataPid,"%d",data) ;
		 	return; 
		 }
		 
	int getsetPid (void){
		int pid[2], ret;
		ret =  read_pid (fd[CurrCpu] , pid );
		if ( ret ) 	return ret;
		
		setPid( pid[0], pid[1]);
		return 0;
	}

public slots:
 	virtual  int show_values(void) =0;
 	void     update_curr_cpu(int cpu_num){
 		PDEBUG( "GUI:update_curr_cpu:CurrCpu=%d update to %d\n",CurrCpu,cpu_num );
		CurrCpu = cpu_num;
		show_values();
		return;
	}
	void setUpdateForce  (void){ UpdatedCpu =-1 ;}
	void setUpdateOnShow ( int _upd) { isUpdateOnShow = _upd;}
protected:
	int isUpdate(void){ return  isUpdateOnShow || (UpdatedCpu != CurrCpu) ; }
    int CurrCpu;
    int UpdatedCpu;
    int isUpdateOnShow;
    char mainPid[10];
    char dataPid[10];
 };



#endif


